package com.socool.sinofaith;

import java.util.ArrayList;
import java.util.HashMap;

import com.baidu.mapapi.SDKInitializer;
import com.socool.sinofaith.util.UnCeHandler;

import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.telephony.TelephonyManager;

public class SocoolApplication extends Application {

	//第一张图片的地址
	public static String firstLocalPicture ; 
	
	private boolean isOffLineLogin = false;
	
	
	public static boolean isFirstFlag = false;
	
	public static String deviceStr= "";
	
	public static ArrayList<HashMap<String, Object>> mapLocalPicture = new ArrayList<HashMap<String, Object>>();

	public boolean isOffLineLogin() {
		return isOffLineLogin;
	}

	public void setOffLineLogin(boolean isOffLineLogin) {
		this.isOffLineLogin = isOffLineLogin;
	}

	
	public static String getIMEI(Context context) {
		
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(context.TELEPHONY_SERVICE);
        String imei = telephonyManager.getDeviceId();

        return imei;
    }
	
	public static ArrayList<Activity> list = new ArrayList<Activity>();

	@Override
	public void onCreate() {
		super.onCreate();
		// 在使用 SDK 各组间之前初始化 context 信息，传入 ApplicationContext
		SDKInitializer.initialize(this);
		// CrashHandler crashHandler = CrashHandler.getInstance();
		// crashHandler.init(getApplicationContext());

		 UnCeHandler catchExcep = new UnCeHandler(this);
		 Thread.setDefaultUncaughtExceptionHandler(catchExcep);
		 deviceStr= getIMEI(this);

	}

	/**
	 * Activity关闭时，删除Activity列表中的Activity对象
	 */
	public void removeActivity(Activity a) {
		list.remove(a);
	}

	/**
	 * 向Activity列表中添加Activity对象
	 */
	public static void addActivity(Activity a) {
		list.add(a);
	}

	/**
	 * 关闭Activity列表中的所有Activity
	 */
	public void finishActivity() {
		for (Activity activity : list) {
			if (null != activity) {
				activity.finish();
			}
		}
		// 杀死该应用进程
		android.os.Process.killProcess(android.os.Process.myPid());
	}

	public void finishActivity222(Activity a) {

	}

}
